import { PackageManagerTabs, Tabs, Tab } from '@theme';

# Node Plugin

Module Federation on the server-side enables many possibilities for backend architecture as well as enables server side rendering of apps.


## Usage

This Runtime Plugin is Provided by the `module-federation/node` package

<PackageManagerTabs
  command={{
    npm: 'npm add @module-federation/enhanced @module-federation/node --save',
    yarn: 'yarn add @module-federation/enhanced @module-federation/node --save',
    pnpm: 'pnpm add @module-federation/enhanced @module-federation/node --save',
    bun: 'bun add @module-federation/enhanced @module-federation/node --save',
  }}
/>


### Configuration

The runtime plugin can be applied at compile-time or runtime
<Tabs>
  <Tab label="Rspack">
  ```typescript title="rspack.config.js"
  const {ModuleFederationPlugin} = require('@module-federation/enhanced/rspack');

  new ModuleFederationPlugin({
    // other options
    runtimePlugins: [
      require.resolve('@module-federation/node/runtimePlugin')
    ]
  });
  ```
  </Tab>
  <Tab label="Webpack">
  ```typescript title="webpack.config.js"
  const {ModuleFederationPlugin} = require('@module-federation/enhanced/webpack');

  new ModuleFederationPlugin({
    // other options
    runtimePlugins: [
      require.resolve('@module-federation/node/runtimePlugin')
    ]
  });
  ```
  </Tab>
  <Tab label="Module Federation Runtime">
    ```typescript title="app.js"
    import {init} from '@module-federation/runtime';
    import nodeRuntimePlugin from '@module-federation/node/runtimePlugin';
    init({
      name: '@demo/app-main',
      remotes: [
        {
          name: '@demo/app2',
          entry: 'http: //localhost:3006/mf-manifest.json',
          alias: 'app2',
        },
      ],
      plugins: [nodeRuntimePlugin()],
    });
    ```
  </Tab>
</Tabs>
